function main() {
  var start = Date.now();
  while (true) {
    startExec();
    var minute = hasRunMinute(start);
    if (minute > 2 * 60) {
      return;
    }
  }
}

function startExec() {
  openApp("快手极速版");
  sleepMinute(getRandom(2, 3));
  wakeUp();
  openAutox();
  sleepMinute(getRandom(2, 3));
  wakeUp();
  goHome();
  sleepMinute(getRandom(2, 3));
  wakeUp();
  openAutox();
  sleepMinute(getRandom(6, 8));
}
function goHome() {
  var intent = app.intent({
    action: Intent.ACTION_MAIN,
    category: Intent.CATEGORY_HOME,
  });
  app.startActivity(intent);
}
function hasRunMinute(start) {
  var end = Date.now();
  var minute = (end - start) / 1000 / 60;
  return minute;
}
function wakeUp() {
  device.wakeUp();
}

function openApp(appName) {
  app.launchApp(appName);
}
function openAutox() {
  app.launchApp("Autox.js v7");
}

function sleepMinute(v) {
  sleep(v * 60 * 1000);
}
function getRandom(min, max) {
  return random(min, max);
}
